package com.haima.ziliao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haima.common.annotation.Log;
import com.haima.common.core.controller.BaseController;
import com.haima.common.core.domain.AjaxResult;
import com.haima.common.enums.BusinessType;
import com.haima.ziliao.domain.PDayinconfig;
import com.haima.ziliao.service.IPDayinconfigService;
import com.haima.common.utils.poi.ExcelUtil;
import com.haima.common.core.page.TableDataInfo;

/**
 * 打印价格Controller
 * 
 * @author hima
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/ziliao/dayinconfig")
public class PDayinconfigController extends BaseController
{
    @Autowired
    private IPDayinconfigService pDayinconfigService;

    /**
     * 查询打印价格列表
     */
    @PreAuthorize("@ss.hasPermi('ziliao:dayinconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(PDayinconfig pDayinconfig)
    {
        startPage();
        List<PDayinconfig> list = pDayinconfigService.selectPDayinconfigList(pDayinconfig);
        return getDataTable(list);
    }

    /**
     * 导出打印价格列表
     */
    @PreAuthorize("@ss.hasPermi('ziliao:dayinconfig:export')")
    @Log(title = "打印价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PDayinconfig pDayinconfig)
    {
        List<PDayinconfig> list = pDayinconfigService.selectPDayinconfigList(pDayinconfig);
        ExcelUtil<PDayinconfig> util = new ExcelUtil<PDayinconfig>(PDayinconfig.class);
        util.exportExcel(response, list, "打印价格数据");
    }

    @GetMapping(value = "/getDyConfig")
    public AjaxResult getDyConfig()
    {
        return success(pDayinconfigService.selectPDayinconfigById(1L));
    }

    /**
     * 获取打印价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('ziliao:dayinconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pDayinconfigService.selectPDayinconfigById(id));
    }

    /**
     * 新增打印价格
     */
    @PreAuthorize("@ss.hasPermi('ziliao:dayinconfig:add')")
    @Log(title = "打印价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PDayinconfig pDayinconfig)
    {
        return toAjax(pDayinconfigService.insertPDayinconfig(pDayinconfig));
    }

    /**
     * 修改打印价格
     */
    @PreAuthorize("@ss.hasPermi('ziliao:dayinconfig:edit')")
    @Log(title = "打印价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PDayinconfig pDayinconfig)
    {
        return toAjax(pDayinconfigService.updatePDayinconfig(pDayinconfig));
    }

    /**
     * 删除打印价格
     */
    @PreAuthorize("@ss.hasPermi('ziliao:dayinconfig:remove')")
    @Log(title = "打印价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pDayinconfigService.deletePDayinconfigByIds(ids));
    }
}
